<%@tag pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<script type="text/javascript">
	jQuery(document).ready(function() {
		jQuery("#button_btn").click(function() {
			var content=getContent();
			var expressStyleName=$("#expressStyleName").val();
			var checkDefault=0;
			if($("#defaultExpressStyle").attr("checked")=="checked"){
   				checkDefault=1;
   			};
   			var temp='&content='+content+'&expressStyleName='+expressStyleName+'&checkDefault='+checkDefault;
   			addAjaxExpressStyle(temp);
		});
	});
	function addAjaxExpressStyle(ajaxTempString) {
		$.ajax({
			type : 'post',
			url : '${ctx}/v2/expressPrinting/addAjaxExpressStyle',
			data : 'logisticsCompanyId=' + $("#logisticsCompanys").val()+ajaxTempString,
			dataType : 'json',
			success : function(data) {
               
                 $("#message").html("<font color=\"red\"><h1>"+data.content+"</h1></font>");
                   $(function () {
                       setTimeout(function () {
                            $("#message").hide();
                       }, 6000);
                  });
                
			},
			error : function() {

			}
		});
	}

	function getAjax() {
		var tempString = "";
		$("#logisticsCompanys_id").html(tempString);
		$.ajax({
			type : 'post',
			url : '${ctx}/v2/expressPrinting/ajaxStyleName',
			data : 'logisticsCompanyId=' + $("#logisticsCompanys").val(),
			dataType : 'json',
			success : function(data) {
				if(data.status=="1"){
				  $.each(data.content, function(i) {
					tempString += "<option value='"+data.content[i].id+"'>"
							+ data.content[i].styleName + "</option>";
				 });
				}else{
				 tempString=data.content;
				}
				$("#logisticsCompanys_id").html(tempString);
			},
			error : function() {
               alert("服务器错误");
			}
		});
	}
	getAjax();

	function DisplayDesign() {
		$("#expressDesign").show();
		LODOP = getLodop(document.getElementById('LODOP2'), document
				.getElementById('LODOP_EM2'));
		LODOP.SET_SHOW_MODE("DESIGN_IN_BROWSE", 1);
		LODOP.PRINT_DESIGN();
	};

	function Moditify(item) {
		LODOP = getLodop(document.getElementById('LODOP2'), document
				.getElementById('LODOP_EM2'));
		if (item.checked) {
			LODOP.ADD_PRINT_TEXTA(item.name, 56, 32, 175, 30, item.value);
		} else {
			LODOP.SET_PRINT_STYLEA(item.name, 'Deleted', !item.checked);
		}
	}
	function getContent() {
		LODOP = getLodop(document.getElementById('LODOP2'), document
				.getElementById('LODOP_EM2'));
		return LODOP.GET_VALUE("ProgramCodes", 0);

	};
</script>

<script type="text/javascript">
	$(document).ready(function() {
		$('#form_upload').ajaxForm({
			dataType : 'json',
			success : processJson
		});
	});
	//加载快递单样式
	function processJson(data) {
	   if(data.status=="1"){
         $("#messageImage").html("<font color=\"red\"><h1>图片上传成功</h1></font>");
                   $(function () {
                       setTimeout(function () {
                            $("#messageImage").hide();
                       }, 6000);
                  });
	  		LODOP.ADD_PRINT_SETUP_BKIMG("<img border='0' src='"+data.message+"'>");
	  }else if(data.status=="0"){
	     alert(data.message);
	  }
	}
</script>


<a href="javascript:DisplayDesign()">设置快递模版</a>

<div class="container-fluid" id="expressDesign" style="display: none">
	<form id="form_upload" action="${ctx}/v2/expressPrinting/addImage"
		method="post" enctype="multipart/form-data">
		<input name="imgFile" id="imgFile" type="file" />
		<input type="submit" value="上传" />
		<input id="cancel_btn" class="btn" type="button" value="打印预览"
	onclick="preview()" />
		<span id="messageImage"></span>
	</form>
	<div class="row-fluid">
		<div class="span10">
			<object id="LODOP2"
				classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=800
				height=500>
				<param name="Caption" value="内嵌显示区域">
				<param name="Border" value="1">
				<param name="Color" value="#C0C0C0">
				<embed id="LODOP_EM2" TYPE="application/x-print-lodop" width=800
					height=450>
			</object>
		</div>
		<div class="span2">
			选项：
			<br>
			<label class="checkbox">
				<input type="checkbox" name="fromAddress" value="寄件人地址"
					onclick="Moditify(this)">
				寄件人地址
			</label>
			<label class="checkbox">
				<input type="checkbox" name="fromName" value="寄件人姓名"
					onclick="Moditify(this)">
				寄件人姓名
			</label>
			<input type="checkbox" name="fromPhone" value="寄件人电话"
				onclick="Moditify(this)">
			寄件人电话
			<label class="checkbox">
				<input type="checkbox" name="fromCompany" value="寄件人单位名称"
					onclick="Moditify(this)">
				寄件人单位名称
			</label>
			<label class="checkbox">
				<input type="checkbox" name="origin" value="始发地"
					onclick="Moditify(this)">
				始发地
			</label>
			<label class="checkbox">
				<input type="checkbox" name="toName" value="收件人姓名"
					onclick="Moditify(this)">
				收件人姓名
			</label>
			<label class="checkbox">
				<input type="checkbox" name="toAddress" value="收件人地址"
					onclick="Moditify(this)">
				收件人地址
			</label>
			<label class="checkbox">
				<input type="checkbox" name="toCompany" value="收货人单位名称"
					onclick="Moditify(this)">
				收货人单位名称
			</label>
			<label class="checkbox">
				<input type="checkbox" name="toPhone" value="收件人电话"
					onclick="Moditify(this)">
				收件人电话
			</label>
			<label class="checkbox">
				<input type="checkbox" name="zipcode" value="邮政编码"
					onclick="Moditify(this)">
				邮政编码
			</label>
			<label class="checkbox">
				<input type="checkbox" name="destination" value="目的地"
					onclick="Moditify(this)">
				目的地
			</label>
			<label class="checkbox">
				<input type="checkbox" name="allCost" value="商品总价"
					onclick="Moditify(this)">
				商品总价
			</label>
			<label class="checkbox">
				<input type="checkbox" name="number" value="商品数量"
					onclick="Moditify(this)">
				商品数量
			</label>
			<label class="checkbox">
				<input type="checkbox" name="productName" value="商品名称"
					onclick="Moditify(this)">
				商品名称
			</label>
			<label class="checkbox">
				<input type="checkbox" name="weight" value="商品重量"
					onclick="Moditify(this)">
				商品重量
			</label>
		</div>
	</div>
</div>
<input id="button_btn" class="btn btn-primary" type="button" value="提交" />
&nbsp;
<input id="cancel_btn" class="btn" type="button" value="返回"
	onclick="history.back()" />
